<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'messageresult.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
   <c:if test="${messagelist!=null}">
 		<form id="form2" method="post">
 		<div>
	    	<table border="1">
	    		<tr>
	    			<th>消息标题</th>
	    			<th>消息类型</th>
	    			<th>消息内容</th>
	    			<th>创建者</th>
	    			<th>发送对象</th>
	    			<th>开始时间</th>
	    			<th>结束时间</th>
	    			<th>创建时间</th>
	    			<th>修改</th>
	    			<th>删除</th>
	    			<th>发布</th>
	    		</tr>
	    			
	    		<c:forEach items="${p.list}" var="m">
	    			<tr>
	    				<td>${m.title}</td>
	    				<td>${m.messagetype.messagetypename}</td>
	    				<td>
	    					<c:choose>
	    						<c:when test="${fn:length(m.content)>6}">
	    							<a href="javascript:showMessageContent('${m.messageid}')">
	    								${fn:substring(m.content,0,6) }....
	    							</a>
	    						</c:when>
	    						<c:otherwise>${m.content}</c:otherwise>
	    					</c:choose>
	    				</td>
	    				<td>${m.userinfo.username}</td>
	    				<td>
	    				<c:forEach items="${messagetouserList}" var="mtu">
					    		<a href="javascript:showMessageTouser('${m.messageid}')">
					    			<c:choose>
					    				<c:when test="${(m.messageid+count).equals('allusers') && m.messageid==mtu.message.messageid}">
					    				所有人	
					    				</c:when>
					    				<c:otherwise>
						    				<c:if test="${m.messageid==mtu.message.messageid}">
						    				${mtu.userinfo.username}	
						    				</c:if>
					    				</c:otherwise>
					    			</c:choose>
					    			
					    		</a>	
			    		</c:forEach>
				    	&nbsp;	
	    				</td>
	    				<td>${m.begintime}</td>
	    				<td>${m.endtime}</td>
	    				<td>${m.recordtime}</td>
	    				<td>
	    				<!-- <input type="button" value="修改" onclick="javascript:document.getElementById('form2').action='hzx/getmessage?type=two&m.messageid=${m.messageid}';document.getElementById('form2').submit();"
	    					<c:if test="${m.ifpublish==1}">disabled="disabled"</c:if>
	    				> -->
	    				<sx:a targets="showm" href="hzx/getmessage?type=two&m.messageid=${m.messageid}"
	    					<s:if test="${m.ifpublish==1}">disabled="disabled"</s:if>
	    				></sx:a>
	    				</td>
	    				<td>
	    				<!-- <a href="javascript:document.getElementById('form2').action='hzx/messageactiondelete?type=delete&m.messageid=${m.messageid}';document.getElementById('form2').submit();" onclick="return confirm('确定删除吗？')">删除</a> -->
	    				<sx:a targets="showm" href="hzx/messageactiondelete?type=delete&m.messageid=${m.messageid}"></sx:a>
	    				</td>
	    				<td>
	    				
	    				<!-- <input type="button" value="发布" onclick="javascript:document.getElementById('form2').action='hzx/messageactionfabu?type=fabu&m.messageid=${m.messageid}';document.getElementById('form2').submit();"
	    					<c:if test="${m.ifpublish==1}">disabled="disabled"</c:if>
	    				> -->
	    				<sx:a targets="showm" href="hzx/messageactionfabu?type=fabu&m.messageid=${m.messageid}"
	    					<s:if test="${m.ifpublish==1}">disabled="disabled"</s:if>
	    				></sx:a>
	    				</td>
	    			</tr>
	    		</c:forEach>
	    	</table>
	    	当前<s:property value="%{#session.p.currentPage}" />页&nbsp;&nbsp;&nbsp;&nbsp;
    		总共<s:property value="%{#session.p.totalPage}" />页&nbsp;&nbsp;&nbsp;&nbsp;
    		<sx:a  href="hzx/haction?type=1&page=1">首页</sx:a>&nbsp;&nbsp;&nbsp;&nbsp;
    		<sx:a  href="hzx/haction?type=1&page=%{#session.p.currentPage-1}">上一页</sx:a>&nbsp;&nbsp;&nbsp;
    		<sx:a  href="hzx/haction?type=1&page=%{#session.p.currentPage+1}">下一页</sx:a>&nbsp;&nbsp;&nbsp;
    		<sx:a  href="hzx/haction?type=1&page=%{#session.p.totalPage}">末页</sx:a>&nbsp;&nbsp;&nbsp;
	    </div>
 		</form>
	 </c:if>
  </body>
</html>
